using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Principal;

namespace Example
{
    public class TestIdentity : IIdentity
    {
        #region IIdentity Members

        public string AuthenticationType
        {
            get { return "Test"; }
        }

        private bool _IsAuthenticated = false;
        public bool IsAuthenticated
        {
            get { return _IsAuthenticated; }
        }

        private string _Name;
        public string Name
        {
            get { return _Name; }
        }

        #endregion

        public void Login(string Name)
        {
            _Roles.Clear();
            _Name = Name;
            _IsAuthenticated = true;
            switch (Name)
            {
                case "Admin":
                    {
                        _Roles.Add("Administrators");
                        break;
                    }
                case "User":
                    {
                        _Roles.Add("Users");
                        break;
                    }
                case "Guest":
                    {
                        break;
                    }
                default:
                    {
                        _Name = null;
                        _IsAuthenticated = false;
                        break;
                    }
            }
        }

        private List<string> _Roles = new List<string>();

        public bool IsInRole(string role)
        {
            return _Roles.Contains(role);
        }
    }
}
